package com.itheima.exam.Exam2;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.Period;

//计算现在距离今年大年初一（2026年1月22日0点0分0秒）还有多少天，多少小时，多少分钟，多少秒？
public class Exam2 {
    public static void main(String[] args) {
        Instant now1 = Instant.now();
        Instant target1 = Instant.parse("2026-02-17T00:00:00.000Z");
        long totalSeconds = Duration.between(now1, target1).getSeconds();
        long days = totalSeconds / (24 * 3600);
        long hours = (totalSeconds % (24 * 3600)) / 3600;
        long minutes = (totalSeconds % 3600) / 60;
        long seconds = totalSeconds % 60;
        System.out.printf("距离2026年2月17日还有%d天%d小时%d分%d秒", days, hours, minutes, seconds);

        Instant now2 = Instant.now();
        Instant target2 = Instant.parse("2026-02-17T00:00:00.000Z");
        Duration duration = Duration.between(now2, target2);
        long days1 = duration.toDays();
        long hours1 = duration.toHours() % 24;
        long minutes1 = duration.toMinutes() % 60;
        long seconds1 = duration.getSeconds() % 60;
        System.out.printf("距离2026年2月17日还有%d天%d小时%d分%d秒", days1, hours1, minutes1, seconds1);

    }
}
